;
var mod_pwd_ops = {
    init:function () {
        this.eventBind();
    },
    eventBind:function () {
        $("#save").click(function () {
            var btn_target = $(this);
            if (btn_target.hasClass("disabled"))
            {
                common_ops.alert("正在处理，请勿重复提交");
                return;
            }

            var oldpass = $("#old_password").val();
            var newpass = $("#new_password").val();

            if(!oldpass)
            {
                common_ops.alert("请输入原始密码");
                return false;
            }

            if(!newpass|| newpass.length < 6)
            {
                common_ops.alert("请输不少于六位的新密码");
                return false;
            }

            btn_target.addClass("disabled");

            var data = {
                new_password:newpass,
                old_password:oldpass
            };

            $.ajax({
                url:common_ops.buildUrl("/user/reset-pwd"),
                type:"POST",
                data:data,
                dataType:'json',
                success:function (res) {
                    btn_target.removeClass("disabled");
                    var callbackFun = null;
                    if(res.code == 200) {
                         callbackFun = function () {
                            window.location.href = window.location.href;
                        }
                    }
                    common_ops.alert(res.msg,callbackFun);
                }
            });



        });
    }
};

$(document).ready(function () {
    mod_pwd_ops.init();
});